#include <av_demo/qls_av_demo_service.h>

/* static */
QMutex QLsAVDemoService::g_centerMutex;
QLsAVDemo *QLsAVDemoService::g_centerWidget = nullptr;

QLsAVDemoService::QLsAVDemoService(QObject *parent) : QObject(parent)
{
}

QLsAVDemoService::~QLsAVDemoService()
{
    if (g_centerWidget) {
        QMutexLocker locker(&g_centerMutex);
        if (g_centerWidget) {
            delete g_centerWidget;
            g_centerWidget = nullptr;
        }
    }
}

/* 返回一个Widget设置到centerwidget中进行显示 */
QWidget *QLsAVDemoService::createView()
{
    if (!g_centerWidget) {
        QMutexLocker locker(&g_centerMutex);
        if (!g_centerWidget)
            g_centerWidget = new QLsAVDemo;
    }
    return g_centerWidget;
}
